from pathlib import Path
from typing import List
import pygame

ASSET_DIR = Path(__file__).parent.absolute()

def load_font(asset_path: str, size: int):
    return pygame.font.Font(
        open(ASSET_DIR / asset_path),
        size
    )
    
def load_image(asset_path: str, scale: float = 1.0):
    img = pygame.image.load(
        open(ASSET_DIR / asset_path)
    )
    
    img = pygame.transform.scale(img, (img.get_size()[0] * scale, img.get_size()[1] * scale))
    return img
    
def load_audio(asset_path):
    return pygame.mixer.Sound(
        open(ASSET_DIR / asset_path)
    )
    
def load_image_from_folder(asset_folder) -> List[pygame.Surface]:
    folder: Path = ASSET_DIR / asset_folder
    ret = []
    for file in folder.rglob('*.png'):
        ret.append(pygame.image.load(open(file)))
        
    return ret

def load_image_convert(asset_path: str):
    return pygame.image.load(
        open(ASSET_DIR / asset_path)
    ).convert()